﻿using NUnit.Framework;
using Medianamik.Core.Sugar;

namespace Tests.Unit.Medianamik.Core
{
    [TestFixture]
    public class StringHelperTests
    {
        [Test]
        public void StripBeforeDismissingMarker()
        {
            const string url = "http://stackoverflow.com/questions/1114470/trim-all-chars-off-file-name-after-first";
            const string marker = "//";
            const bool dismissMarker = true;
            const string result = "stackoverflow.com/questions/1114470/trim-all-chars-off-file-name-after-first";

            Assert.That(url.StripBefore(marker, dismissMarker), Is.EqualTo(result));
        }

        [Test]
        public void StripBeforeNotDismissingMarker()
        {
            const string url = "http://stackoverflow.com/questions/1114470/trim-all-chars-off-file-name-after-first";
            const string marker = "//";
            const bool dismissMarker = false;
            const string result = "//stackoverflow.com/questions/1114470/trim-all-chars-off-file-name-after-first";

            Assert.That(url.StripBefore(marker, dismissMarker), Is.EqualTo(result));
        }

        [Test]
        public void StripAfterDismissingMarker()
        {
            const string url = "http://stackoverflow.com/questions/1114470/trim-all-chars-off-file-name-after-first";
            const string marker = "//";
            const bool dismissMarker = true;
            const string result = "http:";

            Assert.That(url.StripAfter(marker, dismissMarker), Is.EqualTo(result));
        }

        [Test]
        public void StripAfterNotDismissingMarker()
        {
            const string url = "http://stackoverflow.com/questions/1114470/trim-all-chars-off-file-name-after-first";
            const string marker = "//";
            const bool dismissMarker = false;
            const string result = "http://";

            Assert.That(url.StripAfter(marker, dismissMarker), Is.EqualTo(result));
        }
    }
}
